#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
void reverse(char* left, char* right)
{
	while (left < right)
	{
		char tmp = *left;
		*left = *right;
		*right = tmp;
		left++;
		right--;
	}
}
void PrintA(char* start, char* end)
{
	printf(" ");
}
int main()
{
	char arr[50] = { 0 };
	gets(arr);
	int len = strlen(arr) - 1;
	reverse(arr, arr + len);		
	char* start = arr;				
	char* now = arr;
	while (*now != '\0')
	{
		while (*now != ' ' && *now != '\0')			
			now++;
		reverse(start, now - 1);		
		start = now + 1;				
		if (*now != '\0')				
			now++;
	}
	char* start1 = arr;
	char* end1 = arr;
	char* now1 = arr;
	while (*now1 != '\0')
	{
		if (*now1 == ' ')
		{
			start1 = now1;
		while (*now1 == ' ' && *now1 != '\0')
			now1++;
		end1 = now1;
		PrintA(start1, end1);
	    }
		printf("%c", *now1);
		now1++;
	}
	return 0;
}
//
//#include <stdio.h>
//
//#define MAXN 10
//typedef float ElementType;
//
//ElementType Average(ElementType S[], int N);
//
//int main()
//{
//    ElementType S[MAXN];
//    int N, i;
//
//    scanf("%d", &N);
//    for (i = 0; i < N; i++)
//        scanf("%f", &S[i]);
//    printf("%.2f\n", Average(S, N));
//
//    return 0;
//}
//ElementType Average(ElementType S[], int N)
//{
//    int i;
//    double sum, ave;
//    for (i = 0; i < N; i++)
//        sum += S[i];
//    ave = sum / N;
//    return ave;
//}
